import http from "@/api";
import qs from "qs";
//获取知识库列表
export const getKnowledgeList = params => {
  console.log(params);
  return http.post(
    // `/pages/knowledgeInfo!findAllKnowledges.action`,
    `/pages/knowledgeInfo!findAllKnowledges.action`,
    qs.stringify({
      "knowledgeQueryDto.opt": params.opt,
      "knowledgeQueryDto.eventId": params.knowledgeId,
      "knowledgeQueryDto.category": params.knowledgeName,
      "fullTextQueryDTO.queryString": params.queryString,
      "knowledgeQueryDto.title": params.knowledgeTitle,
      "knowledgeQueryDto.creatorFullName": params.knowledgeCreator,
      "knowledgeQueryDto.attachmentContent": params.attachmentContent,
      "knowledgeQueryDto.startTime": params.startTime,
      "knowledgeQueryDto.endTime": params.endTime,
      "knowledgeQueryDto.keyWord": params.keyWord,
      _search: false,
      rows: params.pageSize,
      page: params.pageNum,
      sidx: "kid",
      sord: "desc"
    })
  );
};
//添加知识
export const addKnowledge = params => {
  return http.post(`/pages/knowledgeInfo!saveKnowledgeInfo.action`, qs.stringify(params));
};
//添加前验证
export const checkKnowledge = params => {
  return http.post(`/pages/knowledgeInfo!findKnowledgeByTitle.action`, qs.stringify(params));
};
// 上传文件
export const uploadFile = (params: FormData) => {
  return http.post(`/pages/uploadFile!uploadAttr.action?tenantId=yuehaishuiwu_zhengshi`, params);
};
//编辑知识库
export const editKnowledge = params => {
  return http.post(`/pages/knowledgeInfo!editKnowledgeInfo.action?kid=` + params);
};
//提交编辑知识库
export const editKnowledgeSubmit = params => {
  return http.post(`/pages/knowledgeInfo!updateKnowledgeInfo.action`, qs.stringify(params));
};
//删除知识库
export const delKnowledge = params => {
  return http.post(`/pages/knowledgeInfo!removeKnowledgeItems.action?` + params);
};
//查看知识库
export const getKnowledgeInfo = params => {
  return http.post(`knowledgeInfo!findKnowledgeById.action?kid=` + params);
};
//查看评分
export const getKnowledgeScore = params => {
  return http.post(`/pages/knowledgeInfo!findByIdCommentKnowledge.action?kid=` + params);
};
//提交评分
export const submitKnowledgeScore = params => {
  return http.post(`/pages/knowledgeInfo!saveCommentKnowledge.action`, qs.stringify(params));
};
//编辑新增附件
export const editAddAttachment = params => {
  return http.post(`/pages/eventAttachment!saveEventAttachment.action`, qs.stringify(params));
};
//删除附件
export const delFile = params => {
  return http.post(`/pages/knowledgeInfo!deleteAttachment.action`, qs.stringify(params));
};
